<cfsilent><!---

CF_Kalendar

COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------

Copyright 2006 TJ Downes - tdownes@sanative.net - http://www.sanative.net

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

--->
<!--- attributes.calendarLinkPage - the page that the user is taken to when they click an event --->
<cfparam name="Attributes.calendarLinkPage" type="string" default="" />
<!--- attributes.ExcludeTimeHeader - boolean to specifiy if the header on the calendar for times is displayed --->
<cfparam name="Attributes.ExcludeTimeHeader" type="boolean" default="no" />
<!--- attributes.KalendarRequest  contains the request based data and rules for Kalendar. --->
<cfparam name="Attributes.KalendarRequest" type="any" />
<!--- attributes.urlAddString - a URL string to add to the calendarLinkPage attribute --->
<cfparam name="Attributes.urlAddString" type="string" default="" />
<!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<cfparam name="Attributes.view" type="string" default="list" />


<!--- Config --->
<cfset CategoriesRS = attributes.KalendarRequest.getCategoriesRS() />
<cfset EventRecords = attributes.KalendarRequest.getReturnedEvents()>
<cfset KalendarConfig = attributes.KalendarRequest.getKalendarConfig() />
<cfset LinkDate = attributes.KalendarRequest.getLinkDate() />

<cfset FirstDateOfWeek = attributes.KalendarRequest.getFirstDisplayDateOfMonth() />
<cfset FirstWeekOfMonth = attributes.KalendarRequest.getFirstWeekOfMonth() />
<cfset LastWeekOfMonth = attributes.KalendarRequest.getLastWeekOfMonth() />

</cfsilent>
<a id="top"></a>
<table id="condensedDisplayMainTable">
<tr>
<td style="vertical-align: top;">
<!---- MINI CALENDAR DISPLAY ---->
<cfoutput>
<table class="miniCalendarTable">
<tr>
	<td colspan="7">
	<table style="border-collapse: collapse; padding: 0; margin: 0; width: 100%;">
	<tr>
		<td class="miniCalendarNav">
		<a href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", -1, LinkDate), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.KalendarRequest.getCategoryID()#" title="#DateFormat(DateAdd("m", -1, LinkDate), "mmm yyyy")#">&lt;&lt;</a></td>
		<td class="miniCalendarNav" style="width: 50%">
		<strong>#DateFormat(LinkDate, "mmmm yyyy")#</strong></td>
		<td class="miniCalendarNav">
		<a href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", 1, LinkDate), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.KalendarRequest.getCategoryID()#" title="#DateFormat(DateAdd("m", 1, LinkDate), "mmm yyyy")#&categoryID=#attributes.KalendarRequest.getCategoryID()#">&gt;&gt;</a></td>
	</tr>
	</table>
	</td>
</tr>
<tr>
	<td class="eventDayName">Su</td>
	<td class="eventDayName">Mo</td>
	<td class="eventDayName">Tu</td>
	<td class="eventDayName">We</td>
	<td class="eventDayName">Th</td>
	<td class="eventDayName">Fr</td>
	<td class="eventDayName">Sa</td>
</tr>
</cfoutput>
<cfloop index="LoopWeek" from="#FirstWeekOfMonth#" to="#LastWeekOfMonth#">
<tr>
	<cfloop index="LoopIndex" from="0" to="6">
	<cfset EventExists = 0 />
	<td class="eventDayHeader">
	<cfsilent>
	<cfloop index="i" from="1" to="#ArrayLen(EventRecords)#">
		<cfif CreateODBCDate(eventRecords[i].StartDate) lte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
			<cfif CreateODBCDate(eventRecords[i].EndDate) gte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
				<cfset EventExists = 1 />
			</cfif>
		</cfif>
	</cfloop>
	</cfsilent>
	<cfoutput>
	<cfset thisDay = DateAdd('d', LoopIndex, FirstDateOfWeek) />
	<cfif Month(DateAdd('d', LoopIndex, FirstDateOfWeek)) eq Month(LinkDate)><cfif EventExists><div class="miniCalendarDayClass"><a href="###Day(thisDay)#" class="calendardates2">#Day(thisDay)#</a></div><cfelse>#Day(DateAdd('d', LoopIndex, FirstDateOfWeek))#</cfif></cfif></cfoutput></td>
	</cfloop>
</tr>
<cfset FirstDateOfWeek = CreateODBCDate(DateAdd('d', 7, FirstDateOfWeek)) />
</cfloop>
</table><br />
<cfform method="post" action="#cgi.SCRIPT_NAME#" id="viewchange" class="allForms">
<div><input type="hidden" name="LinkDate" value="<cfoutput>#LinkDate#</cfoutput>" id="LinkDate" />
<input type="hidden" name="categoryID" value="<cfoutput>#attributes.KalendarRequest.getCategoryID()#</cfoutput>" />
<select name="view" class="calendarSelectBoxes" onchange="document.getElementById('viewchange').submit();">
	<option value="day">day</option>
	<option value="week">week</option>
	<option value="weeklist">week list</option>
	<option value="month">month</option>
	<option value="list" selected="selected">condensed</option>
</select></div>
</cfform>
<cfform method="post" action="#cgi.script_name#" id="categoryChange" class="allForms">
<div><input type="hidden" name="linkdate" value="<cfoutput>#LinkDate#</cfoutput>" id="linkdate" />
<input type="hidden" name="view" value="<cfoutput>#attributes.view#</cfoutput>" />
<select name="categoryID" class="calendarSelectBoxes" onchange="document.getElementById('categoryChange').submit();">
	<cfoutput query="CategoriesRS">
	<option value="#categoryID#"<cfif attributes.KalendarRequest.getCategoryID() eq categoryID> selected</cfif>>#left(categoryName, 25)#</option>
	</cfoutput>
	<option value="0"<cfif attributes.KalendarRequest.getCategoryID() eq 0> selected</cfif>>all</option>	
</select></div></cfform>
<cfif KalendarConfig.hasMiniCalendarInclude()><br />
	<cfinclude template="#KalendarConfig.getMiniCalendarPath()#" />
</cfif>
</td>
<td style="width: 10px"></td>
<td style="vertical-align: top;">
	<cfif ArrayLen(EventRecords) neq 0>
	<table class="condensedList">
	<cfloop index="i" from="1" to="#ArrayLen(EventRecords)#">
	<cfif Month(eventRecords[i].StartDate) eq Month(LinkDate) OR Month(eventRecords[i].EndDate) eq Month(LinkDate)>
	<cfoutput>
	<tr class="eventListItem"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>>
		<td style="width: 100px;"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#DateFormat(eventRecords[i].StartDate, "mmm dd")#<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate> - #DateFormat(eventRecords[i].EndDate, "mmm dd")#</cfif></td>
		<td><a href="###eventRecords[i].EventID#-id"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#eventRecords[i].Title#</a></td>
	</tr>
	</cfoutput>
	<tr>
	   <td colspan="2" class="condensedListSeperator">&nbsp;</td>
	</tr>
	</cfif>
	</cfloop>
	</table>
	</cfif>
	</td>
</tr>
</table>
<cfif KalendarConfig.getShowDetailsUnderMiniCalendar() >
<p />
<cfif ArrayLen(EventRecords) neq 0>
<table id="miniCalendarDetailTable">
<!--- Display Individual Events --->
<cfloop index="i" from="1" to="#ArrayLen(EventRecords)#">
	<cfif Month(eventRecords[i].StartDate) eq Month(LinkDate) OR Month(eventRecords[i].EndDate) eq Month(LinkDate)>
	<cfoutput>
	<tr>
		 <td valign="top"><a id="evid-#eventRecords[i].EventID#" style="display: none;"></a>
		#DateFormat(eventRecords[i].StartDate, "dddd, mmmm dd")#<cfif len(trim(eventRecords[i].StartTime))> #TimeFormat(eventRecords[i].StartTime, 'h:mm tt')#</cfif><cfif eventRecords[i].StartDate neq eventRecords[i].EndDate> - #DateFormat(eventRecords[i].EndDate, "dddd, mmmm dd")#</cfif><cfif len(trim(eventRecords[i].EndTime))><cfif NOT len(trim(eventRecords[i].EndDate))>-</cfif> #TimeFormat(eventRecords[i].EndTime, 'h:mm tt')#</cfif><br />
		<a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(LinkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url"><span class="miniCalendarEventDisplayHeader">#eventRecords[i].Title#</span></a><br />
		#eventRecords[i].Location#
		<p />
		#eventRecords[i].Description#
		<p />
		<cfif Len(Trim(eventRecords[i].ContactPhone))>For more information, call #eventRecords[i].ContactPhone#.<br /></cfif>
		<cfif Len(Trim(eventRecords[i].ContactEmail))>Email: <a href="mailto:#eventRecords[i].ContactEmail#">#eventRecords[i].ContactEmail#</a>.</cfif>
		<p />
		<div  style="text-align: center;"><a href="##top">Back to top</a></div>
		<!--- This is for microformats. --->
		<div style="display:none;" class="vevent">
		<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
		<span class="summary title">#Trim(eventRecords[i].Title)#</span>
		<a href="http://#cgi.server_name#/#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(LinkDate)#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
		<div class="description">#eventRecords[i].Description#</div>
		<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif>">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#<cfif Len(Trim(eventRecords[i].StartTime))>T#TimeFormat(eventRecords[i].StartTime, "HH:mm:ss")#</cfif></span>
		<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate AND eventRecords[i].StartTime neq eventRecords[i].EndTime><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif>"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif><cfif Len(Trim(eventRecords[i].EndTime))>T#TimeFormat(eventRecords[i].EndTime, "HH:mm:ss")#</cfif></span></cfif></div>
		</td>
	</tr></cfoutput></cfif></cfloop></table></cfif></cfif>